package org.example.Lambda;

import java.util.function.IntBinaryOperator;

/** @ClassName: LambdaDemo02 @Author NeySun @Description: TODO @Version 1.0 @Date 2022-03-03 */
public class LambdaDemo02 {
  public static void main(String[] args) {
    // 1.列表+返回结果
    // alt+回车生成lamda表达式
    // 光标点到列表repalace就是lamda还原
    int i = calculateNum((left, right) -> left + right);
    System.out.println(i);
    // 2.列表+返回结果
    int i2 = calculateNum(Integer::sum);
    System.out.println(i2);
  }

  public static int calculateNum(IntBinaryOperator operator) {
    int a = 10;
    int b = 20;
    return operator.applyAsInt(a, b);
  }
}
